import { Suspense, useEffect } from 'react';
import { useLocation, useRoutes } from 'react-router-dom';
import routes from '@/router/index.tsx';
import authRoute from '@/router/AuthRouter';
import { useRouter } from './hooks/useRouter';

function App() {
	const location = useLocation();
	const router = useRouter();

	useEffect(() => {
		authRoute({ currentPath: location.pathname, router });
	}, [location.pathname]);
	return (
		<>
			<Suspense fallback="">
				<div className="main">{useRoutes(routes)}</div>
			</Suspense>
		</>
	);
}

export default App;
